#include <unordered_map>
#include <cstdio>

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

/**
 *
 * 保龄球
 * https://www.luogu.com.cn/problem/P1918
 */
int main() {

    ios::sync_with_stdio(false);
    cin.tie(NULL);


    unordered_map<int, int> numMap;

    int n = read();
    for (int i = 1; i <= n; ++i) {
        int ai = read();
        numMap[ai] = i;
    }

    int Q = read();
    while (Q--) {
        int m = read();

        if (numMap.count(m)) {
            cout << numMap[m]  << "\n";
        }
        else {
            cout << "0\n";
        }
    }

    return 0;
}
